package com.qijian.tool.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 文件上传配置文件
 */
@Data
@Component
//@ConfigurationProperties(prefix = "file")
//@PropertySource(value = {"classpath:file.yml"})
public class FileProperties {

    /**
     * 文件大小限制
     */
    private Long maxSize = 100L;

    /**
     * 头像大小限制
     */
    private Long avatarMaxSize = 5L;

    private QJPath mac = new QJPath();

    private QJPath linux;

    private QJPath windows;

    public QJPath getPath() {
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            return windows;
        } else if (os.toLowerCase().startsWith("mac")) {
            return mac;
        }
        return linux;
    }

    @Data
    public static class QJPath {

        private String path;

        private String avatar;

        public QJPath() {
        }

        public QJPath(String path, String avatar) {
            this.path = path;
            this.avatar = avatar;
        }
    }
}
